package com.gujiangbo.observable;


public interface TaskLifecycle<T> {

    //任务启动时触发onStart方法
    void onStart(Thread thread);

    //任务正在运行触发onRunning方法
    void onRunning(Thread thread);

    //任务运行完成触发onFinish方法
    void onFinish(Thread thread, T result);

    //任务运行报错触发onError方法
    void onError(Thread thread, Exception e);

    //空实现 Adapter
    class EmptyLifecycle<T> implements TaskLifecycle<T> {

        @Override
        public void onStart(Thread thread) {

        }

        @Override
        public void onRunning(Thread thread) {

        }

        @Override
        public void onFinish(Thread thread, T result) {

        }

        @Override
        public void onError(Thread thread, Exception e) {

        }
    }
}
